package com.liner;

/**
 * @author liner
 */
public class TypeConv {
    public static void main(String[] args) {
        /*
         *  数据类型转换
         */

        //强制转换可能发生丢精度
        double a = 12.32;
        int b = (int) a;
        System.out.println(b);

        //强制转换可能发生溢出
        long c = 1000000000000L;
        int d = (int) c;
        System.out.println(d);

        double e = 1.123123123123123123123123;
        float f = (float) e;
        System.out.println(f);

        /*
         * 两点规则
         * 整数直接量可以直接赋值给 byte，char，short 只要不超范围即可
         * byte，char，short 在参与运算时候 自动转换成 int类型 进行运算
         *
         */
        //0 -> 48  2 -> 50
        int two = '你';
        System.out.println(two);

        byte ee = 1;
        byte ff = 2;
        byte gg = (byte) (ee + ff);
        System.out.println(gg);

        char aa = (byte) 12;
        System.out.println(aa);

        byte bb = 12;
        char cc = (char) bb;
        System.out.println(cc);

        System.out.println('2'); //50
        System.out.println('2' + '2');  //100
        System.out.println(2 + '2'); //52
        System.out.println(2 + 2); //4



    }
}
